#include <bits/stdc++.h>
#define MAXN 35
#define ll long long
using namespace std;

int cnt, head[MAXN], s, t, xu[1023 << 1];

inline int get_num() {
	int k = 0;
	char c = getchar();
	for(; !isdigit(c); c = getchar());
	for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
	return k; 
}

struct edge {
	int to, fr, ne;
	ll v;
	edge() {;}
	edge(int to_, int fr_, int ne_, ll v_) {
		to = to_;
		fr = fr_;
		ne = ne_;
		v = v_;
	}
}e[1023 << 1];

inline void addedge(int fr, int to, ll v) {
	e[cnt] = edge(to, fr, head[fr], v), head[fr] = cnt++;
	e[cnt] = edge(fr, to, head[to], 0), head[to] = cnt++;
}

int m, n, pth[MAXN], dep[MAXN], vis[MAXN], micar = 0x7fffffff;

inline bool bfs() {
	memset(pth, -1, sizeof(pth));
	memset(vis, 0, sizeof(vis));
	memset(dep, 0, sizeof(dep));
	queue <int> q;
	q.push(s);
	vis[s] = 1;
	while(!q.empty()) {
		int x = q.front();
		q.pop();
		for(int i = head[x]; ~i; i = e[i].ne) {
			int y = e[i].to;
			if(vis[y] || !e[i].v) continue;
			dep[y] = dep[x] + 1;
			vis[y] = 1;
			pth[y] = i;
			q.push(y);
		}
	}
	return ~pth[t];
}

inline int get_flow() {
	int now =pth[t];
	int flow = 0x7fffffff;
	while(~now) {
		flow = min(flow, (int)e[now].v);
		now = pth[e[now].fr]; 
	}
	now = pth[t];
	while(~now) {
		e[now].v -= flow;
		e[now ^ 1].v += flow;
		now = pth[e[now].fr];
	}
	return flow;
}

inline int get_road() {
	int now =pth[t];
	int flow = 0x7fffffff;
	while(~now) {
		flow = min(flow, (int)e[now].v);
		micar = min(micar, xu[now]);
		printf("%d ", xu[now]);
		now = pth[e[now].fr]; 
	}
	now = pth[t];
	while(~now) {
		e[now].v -= flow;
		e[now ^ 1].v += flow;
		now = pth[e[now].fr];
	}
	return flow;
}

int main() {
//	freopen("milk6.in", "r", stdin);
//	freopen("milk6.out", "w", stdout);
	memset(head, -1, sizeof(head));
	n = get_num();
	m = get_num();
	s = 1;
	t = n;
	for(int i = 1; i <= m; i++) {
		int x = get_num();
		int y = get_num();
		int z = get_num();
		xu[cnt] = i;
		addedge(x, y, z);
	}
	int ans = 0;
	while(bfs()) {
		ans += get_flow();
	}
	printf("%d ", ans);
	ans = 0;
	for(int i = 0; i < cnt; i++) {
		if(e[i].v) e[i].v = 0x7fffffff;
		else e[i].v = 1;
	}
	while(bfs()) {
		ans += get_road();
	}
	printf("%d %d", ans, micar);
}
